package service

import (
	"tdy-backend/app/core/service"
	"tdy-backend/app/panoramic/dto"
	"tdy-backend/app/panoramic/model"
)

type SpotService struct {
	service.BaseService
}

//新增热点
func (o *SpotService) Add(param *dto.SpotAddDto) (*model.Spot, error) {
	db := o.DB
	sceneService := SceneService{}
	sceneService.MakeORM(db).MakeMemberInfo(o.MemberInfo)
	_, err := sceneService.GetSceneOneRow(param.SceneId)
	if err != nil {
		return nil, err
	}

	spot := model.Spot{}
	spot.Title = param.Title
	spot.MemberId = o.MemberInfo.ID
	spot.SceneId = param.SceneId
	spot.IsShowTitle = param.IsShowTitle
	spot.OpenType = param.OpenType
	spot.Type = param.Type
	spot.IconImage = param.IconImage
	spot.ToSceneId = param.ToSceneId
	spot.ToUrl = param.ToUrl
	spot.Atv = param.Atv
	spot.Ath = param.Ath

	create := db.Create(&spot)
	if create.Error != nil {
		return nil, create.Error
	}
	return &spot, nil
}

//删除热点
func (o *SpotService) Delete(param dto.SpotDeleteDto) {

}

//TODO
func (o *SpotService) Edit(param dto.SpotEditDto) {

}

//TODO
func (o *SpotService) ListAll(param dto.SpotListDto) {

}
